package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private  SupplierService supplierService;


    /*
    分页查询供应商
    Interger page(当前页数)
    Interger rows(每页显示的记录数)
    String supplierName(供应商名字)
     */
    @PostMapping("/list")
    public Map<String,Object> list(Integer page,Integer rows,String supplierName){

        return supplierService.list(page,rows,supplierName);
    }

    /*
    查询下拉框
    q 供应商名称
     */

    @RequestMapping("/getComboboxList")
    public List<Supplier> getComboboxList(String q){
        return supplierService.getComboboxList(q);
    }


    @PostMapping("/save")
    public ServiceVO save(Supplier supplier){
        return  supplierService.save(supplier);

    }
}
